﻿using AiMoBridge.Paths;
using System.IO;

namespace AiMoWindows.MainActions.ScriptActions.SubActions
{
    class MainButtonAction(ActionsController owner)
    {
        readonly ActionsController owner = owner;
        bool m_OnRunningScript = false;
        public async void RunButton_Click()
        {
            if (m_OnRunningScript) return;
            m_OnRunningScript = true;
            owner.ClearDebugPrint();
            await owner.ExecuteAction.ExecuteCode();
            m_OnRunningScript = false;
        }
        public void OpenAiWindow()
        {
            Entrance.AiMoProgram.Instance.OpenNewAiMoAiWindow();
        }
        public void OpenCommandLibraryWindow()
        {
            Entrance.AiMoProgram.Instance.OpenOrShowCommandLibraryWindow();
        }
        public void ShowAiMoFolder()
        {
            // 实现显示AiMo文件夹的逻辑
            try
            {
                string path = PathManager.MainFolder;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                ActionsUtils.OpenPath(path);
            }
            catch (Exception ex)
            {
                owner.Printer.PrintDebug("Cannot Open AiMo Folder: " + ex.FormatException());
            }
        }
    }
}
